<?php

namespace App\Providers;

/**
 * 重写分页返回数组
 * Class LengthAwarePaginatorProvider
 */
class LengthAwarePaginatorProvider extends \Illuminate\Pagination\LengthAwarePaginator
{
    public function toArray()
    {
        return [
            'page' => [
                'current_page' => $this->currentPage(),
                'last_page' => $this->lastPage(),
                'per_page' => $this->perPage(),
                'page' => $this->currentPage(),
                'page_size' => $this->perPage(),
                'total' => $this->total(),
            ],
            'data' => $this->items->toArray()
            // 'first_page_url' => $this->url(1),
            // 'from' => $this->firstItem(),
            // 'last_page_url' => $this->url($this->lastPage()),
            // 'links' => $this->linkCollection()->toArray(),
            // 'next_page_url' => $this->nextPageUrl(),
            // 'path' => $this->path(),
            // 'prev_page_url' => $this->previousPageUrl(),
            // 'to' => $this->lastItem(),
        ];
    }
}
